home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11890 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: tank.news.pipex.net!pipex!iol!usenet
  2. From: David Byrden <goyra@iol.ie>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: overloading ->
  5. Date: 16 Mar 1996 22:07:27 GMT
  6. Organization: Ireland On-Line
  7. Message-ID: <4ife2v$m8o@nuacht.iol.ie>
  8. References: <4id6o2$t5n@vixen.cso.uiuc.edu> <4ie274$pc1@sam.inforamp.net>
  9. NNTP-Posting-Host: dialup-184.dublin.iol.ie
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22KIT (Windows; I; 16bit)
  14.  
  15.  
  16. rmorin@inforamp.net (Randy Charles Morin) wrote:
  17. >In article <4id6o2$t5n@vixen.cso.uiuc.edu>,
  18. >   wemccaug@prairienet.org (Wendy E. McCaughrin) wrote:
  19. >> I realize that in addition to returning an object pointer
  20. >> as value, a member operator -> can also return an object,
  21. >> but I am wondering if there is a way to overload it so it
  22. >> can return two different pointer types directly. My problem
  23. >> is that it has to be a member operator taking no arguments,
  24. >> so the different return-values would be the only distinction
  25. >> and, of course, that is not enough to make them regarded as
  26. >> different by the compiler. Any suggestions?
  27. >
  28. >Here's what I'm thinking.  You have a primary class member function that 
  29. >returns a secondary class.  The secondary class has built-in implicit type 
  30. >conversion routines that pass one value when converting to type x and another 
  31. >when converting to type y.
  32. >
  33. >class Primary
  34. >{
  35. >public:
  36. >    Secondary get(){Secondary s; s.i=0; s.c=0; return s;};
  37. >};
  38. >
  39. >class Secondary
  40. >{
  41. >public:
  42. >    int i;
  43. >    char c;
  44. >};
  45. >
  46.  
  47.       The primary class was supposed to have operator->() return something 
  48. interesting, so a get() function is of no use.
  49.  
  50.      If operator-> returns an object with implicit conversions to two 
  51. pointer types, what will make the choice between them?
  52.  
  53.  
  54.                                   David
  55.  
  56.  
  57.